package controller

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"wms/define"
	"wms/logic"
)

// GetFuncListHandler 获取功能列表
// @Summary 获取功能列表接口
// @Description 鉴权后用户需要可以拉取对应的功能列表信息
// @Tags 功能相关接口
// @Accept application/json
// @Produce application/json
// @Param Authorization header string true "Bearer 用户令牌"
// @Success 200 {object} define.DocResponseData
// @Router /settings/func/get/list [get]
func GetFuncListHandler(c *gin.Context) {
	mc := c.MustGet("MyClaims").(*define.MyClaims)

	//funcBasics := make([]*models.FunctionBasic, 0)
	//if err := logic.GetFuncList(mc, &funcBasics); err != nil {
	fl := make([]*define.FuncListReply, 0)

	if err := logic.GetFuncListWithMenuIdentity(mc, &fl); err != nil {
		zap.L().Error("logic.GetFuncList failed", zap.Error(err))
		define.ResponseError(c, define.CodeServerBusy)
		return
	}

	define.ResponseSuccess(c, define.CodeSuccess, fl)
}
